package client.net.handler;

import client.Client;
import java.nio.ByteBuffer;

/**
 * Tell the client that the observed game has ended.
 * 
 * @author Vincent Tsuei
 * @version 2012-11-29
 */
public class ObserveGameEndHandler implements ClientPacketHandler {

    @Override
    public int processPacket(Client client, ByteBuffer packet) {
        long gameID = packet.getLong();
        if (client.getExpectUnobserve()) {
            client.getUserIO().write("You have stopped observing the game [ID: "+gameID+"].", true);
        } else {
            client.getUserIO().write("The game you are observing [ID: "+gameID+"] has ended.", true);
            
            client.setLobby();
        }
        return 0;
    }
    
}
